import Mock from "mockjs";

//Random方法是mockjs的核心方法，可以生成各种占位符
const Random = Mock.Random;

// 如果下面直接这样写，只是模拟了一段静态的json文件
let json = Mock.mock({
  // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
  "list|1-10": [
    {
      // 属性 id 是一个自增数，起始值为 1，每次增 1
      "id|+1": 1,
    },
  ],
});
// export default json;  //这样只是导出了一段json,需要在使用的地方直接导入即可

// 如果是想通过模拟接口来使用数据，可以这样做：
Mock.mock("/test_api/test", "get", {
  code: 200,
  msg: "操作成功",
  "data|5-12": [
    {
      //随机生成guid
      guid: "@guid",
      // 属性名|生成规则:属性值
      "company|1": ["CSDN", "阿里巴巴", "腾讯", "百度", "华为"],
      companyDescription: "@cparagraph(4)",
      logo: function () {
        return Random.image("36x36", "#d8d8d8", "#000", "png", "Logo");
      },
      "city|1": "长沙市岳麓区",
      "positionTitle|+1": ["Java开发工程师", "Python开发工程师", "前端开发工程师", "产品经理", "UI设计师", "IOS研发工程师", "安卓研发工程师"],
      // 薪资
      "salaryRange|1": ["5k-8k", "10k-15k", "15k-20k"],
      // 工作年限
      "workTime|2-10": 2,
      // 招聘人数
      "recruitNumber|1-5": 1,
      // 学历
      "degree|1": ["本科", "硕士", "博士"],
      // 上架时间
      launchTime: '@date("yyyy-MM-dd")',
      // 职位描述
      jobDescription: "@cparagraph(5)",
    },
  ],
});

// 测试失败
Mock.mock("/test_api/testerror", "get", {
  code: 400,
  msg: "操作失败",
  data: [],
});

// 测试失败无权限
Mock.mock("/test_api/testerror401", "get", {
  code: 401,
  msg: "操作失败！无权限！",
  data: [],
});

// 获取权限信息
Mock.mock("/test_api/v1/token", "post", {
  code: 200,
  msg: "操作成功",
  data: {
    token: "adminToken1.0.2",
    userInfo: {
      roles: ["sa", "admin", "auditor"],
      userId: 2,
      userName: "Administrator",
    },
    settingConfig: {
      // 是否开启布局配置抽屉
      isDrawer: false,
      /**
       * 布局切换
       * 注意：为了演示，切换布局时，颜色会被还原成默认，代码位置：/@/layout/navBars/breadcrumb/setings.vue
       * 中的 `initSetLayoutChange(设置布局切换，重置主题样式)` 方法
       */
      // 布局切换：可选值"<default|classic|transverse|columns>"，默认 defaults
      layout: "default",

      // 颜色
      color: "#409EFF",

      // 是否开启深色模式
      isDark: false,

      // 是否开启灰色模式
      isGrayscale: false,

      // 是否开启色弱模式
      isInvert: false,

      // 默认初始语言，可选值"<zh-cn|en|zh-tw>"，默认 zh-cn
      globalI18n: "zh-cn",
    },
  },
});

// 获取菜单信息
Mock.mock("/test_api/v1/menu", "get", {
  code: 200,
  data: {
    menu: [
      {
        name: "home",
        path: "/home",
        redirect: "/home/index",
        meta: {
          title: "首页",
          icon: "Eleme",
        },
        children: [
          {
            name: "dashboard",
            path: "/dashboard",
            component: "/home/index",
            meta: {
              title: "控制台",
              icon: "Menu",
              isAffix: true,
            },
          },
          {
            name: "dashboard2",
            path: "/dashboard2",
            component: "/home/index2",
            meta: {
              title: "控制台2",
              icon: "Menu",
              isAffix: true,
            },
          },
          {
            name: "userCenter",
            path: "/userCenter",
            component: "/userCenter/index",
            meta: {
              title: "账号信息",
              icon: "User",
              tag: "标签",
            },
          },
        ],
      },
      {
        name: "vab",
        path: "/vab",
        meta: {
          title: "组件",
          icon: "TakeawayBox",
        },
        children: [
          {
            name: "iconfont",
            path: "/vab/iconfont",
            component: "/vab/iconfont/index",
            meta: {
              title: "拓展图标",
              icon: "Orange",
            },
          },
          {
            name: "data",
            path: "/vab/data",
            meta: {
              title: "数据展示",
              icon: "Histogram",
            },
            children: [
              {
                name: "statistic",
                path: "/vab/data/statistic",
                component: "/vab/data/statistic",
                meta: {
                  title: "统计数值",
                },
              },
              {
                name: "echarts",
                path: "/vab/data/echarts",
                component: "/vab/data/echarts",
                meta: {
                  title: "图表",
                },
              },
              {
                name: "qrcode",
                path: "/vab/data/qrcode",
                component: "/vab/data/qrcode",
                meta: {
                  title: "二维码",
                },
              },
            ],
          },
          {
            name: "form",
            path: "/vab/form",
            meta: {
              title: "Form 数据录入",
              icon: "Edit",
            },
            children: [
              {
                name: "selectFilter",
                path: "/vab/form/selectFilter",
                component: "/vab/form/selectFilter",
                meta: {
                  title: "分类筛选器",
                },
              },
              {
                name: "treeFilter",
                path: "/vab/form/treeFilter",
                component: "/vab/form/treeFilter",
                meta: {
                  title: "树形筛选器",
                  tag: "1.0.2",
                },
              },
              {
                name: "query",
                path: "/vab/form/query",
                component: "/vab/form/query",
                meta: {
                  title: "查询器",
                },
              },
              {
                name: "uploadImg",
                path: "/vab/form/uploadImg",
                component: "/vab/form/uploadImg",
                meta: {
                  title: "图片上传",
                },
              },
              {
                name: "iconSelect",
                path: "/vab/form/iconSelect",
                component: "/vab/form/iconSelect",
                meta: {
                  title: "图标选择器",
                },
              },
              {
                name: "editor",
                path: "/vab/form/editor",
                component: "/vab/form/editor",
                meta: {
                  title: "富文本编辑器",
                },
              },
              {
                name: "verify",
                path: "/vab/form/verify",
                component: "/vab/form/verify",
                meta: {
                  title: "验证码",
                },
              },
              {
                name: "formTable",
                path: "/vab/form/formTable",
                component: "/vab/form/formTable",
                meta: {
                  title: "表单表格",
                },
              },
            ],
          },
          {
            name: "table",
            path: "/vab/table",
            redirect: "/vab/table/index",
            meta: {
              title: "表格",
              icon: "List",
              tag: "1.0.2",
            },
            children: [
              {
                name: "tableIndex",
                path: "/vab/table/index",
                component: "/vab/table/index",
                meta: {
                  title: "基础表格",
                },
              },
              {
                name: "tableRadio",
                path: "/vab/table/radio",
                component: "/vab/table/radio",
                meta: {
                  title: "单选表格",
                },
              },
              {
                name: "tableSelection",
                path: "/vab/table/selection",
                component: "/vab/table/selection",
                meta: {
                  title: "多选表格",
                },
              },
              {
                name: "tableSort",
                path: "/vab/table/sort",
                component: "/vab/table/sort",
                meta: {
                  title: "拖动排序",
                },
              },
              {
                name: "tableExpand",
                path: "/vab/table/expand",
                component: "/vab/table/expand",
                meta: {
                  title: "展开表格",
                },
              },
              {
                name: "tableCustomHeader",
                path: "/vab/table/customHeader",
                component: "/vab/table/customHeader",
                meta: {
                  title: "自定义表格头部",
                },
              },
              {
                name: "tableCustomContent",
                path: "/vab/table/customContent",
                component: "/vab/table/customContent",
                meta: {
                  title: "自定义表格内容",
                },
              },
              {
                name: "tableCustomBottom",
                path: "/vab/table/customBottom",
                component: "/vab/table/customBottom",
                meta: {
                  title: "自定义表格底部",
                },
              },
              {
                name: "tableSearch",
                path: "/vab/table/search",
                component: "/vab/table/search",
                meta: {
                  title: "条件查询表格",
                },
              },
              {
                name: "tableDetail",
                path: "/vab/table/detail/:id",
                component: "/vab/table/detail",
                meta: {
                  title: "表格详情",
                  isHide: true,
                },
              },
            ],
          },
        ],
      },
      {
        name: "other",
        path: "/other ",
        redirect: "/other/layout",
        meta: {
          title: "其它 ",
          icon: "MoreFilled",
        },
        children: [
          {
            name: "otherlayout",
            path: "/other/layout",
            component: "/other/layout",
            meta: {
              title: "布局",
              icon: "Grid",
            },
          },
          {
            name: "otherDirective",
            path: "/other/directive",
            component: "/other/directive",
            meta: {
              title: "指令",
              icon: "Discount",
            },
          },
          {
            name: "otherKeepAlive",
            path: "/other/keepAlive",
            component: "/other/keepAlive",
            meta: {
              title: "页面保活(KeepAlive)",
              icon: "CollectionTag",
              isKeepAlive: true,
            },
          },
          {
            name: "otherIframe",
            path: "/other/iframe",
            component: "/other/iframe",
            meta: {
              title: "iframe",
              icon: "Reading",
            },
          },
          {
            name: "otherFull",
            path: "/other/full",
            component: "/other/full",
            meta: {
              title: "全屏展示",
              icon: "FullScreen",
              isFull: true,
            },
          },
          {
            name: "otherLink",
            path: "https://www.baidu.com",
            component: "/other/link",
            meta: {
              title: "外部链接",
              icon: "Link",
              type: "LINK",
            },
          },
        ],
      },
      {
        name: "bigscreen ",
        path: "/bigscreen",
        redirect: "/bigscreen/index",
        meta: {
          title: "大屏管理",
          icon: "Eleme",
        },
      },
    ],
    permissions: ["list.add", "list.edit", "list.delete", "user.add", "user.edit", "user.delete"],
  },
  message: "",
});

// 获取站点配置
Mock.mock("/test_api/v1/siteconfig", "get", {
  code: 200,
  msg: "操作成功",
  data: {
    site_url: "#",
    site_title: "OneSeveAdmin",
  },
});

// 首页数据
Mock.mock("/test_api/v1/dashboard", "get", {
  code: 200,
  msg: "操作成功",
  data: {
    lineChart: {
      title: {
        text: "堆积图",
        textStyle: {
          color: "#a1a1a1",
        },
      },
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "cross",
          label: {
            backgroundColor: "#6a7985",
          },
        },
      },
      legend: {
        data: ["Email", "Union Ads", "Video Ads", "Direct", "Search Engine"],
        textStyle: {
          color: "#a1a1a1",
        },
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true,
      },
      xAxis: [
        {
          type: "category",
          boundaryGap: false,
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
          axisLabel: {
            color: "#a1a1a1",
          },
        },
      ],
      yAxis: [
        {
          type: "value",
          axisLabel: {
            color: "#a1a1a1",
          },
        },
      ],
      series: [
        {
          name: "Email",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [120, 132, 101, 134, 90, 230, 210],
        },
        {
          name: "Union Ads",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [220, 182, 191, 234, 290, 330, 310],
        },
        {
          name: "Video Ads",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [150, 232, 201, 154, 190, 330, 410],
        },
        {
          name: "Direct",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [320, 332, 301, 334, 390, 330, 320],
        },
        {
          name: "Search Engine",
          type: "line",
          stack: "Total",
          label: {
            show: true,
            position: "top",
          },
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [820, 932, 901, 934, 1290, 1330, 1320],
        },
      ],
    },
    columnChart: {
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "shadow",
        },
      },
      legend: {
        textStyle: {
          color: "#a1a1a1",
        },
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true,
      },
      xAxis: [
        {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
          axisLabel: {
            color: "#a1a1a1",
          },
        },
      ],
      yAxis: [
        {
          type: "value",
          axisLabel: {
            color: "#a1a1a1",
          },
        },
      ],
      series: [
        {
          name: "Direct",
          type: "bar",
          emphasis: {
            focus: "series",
          },
          data: [320, 332, 301, 334, 390, 330, 320],
        },
        {
          name: "Email",
          type: "bar",
          stack: "Ad",
          emphasis: {
            focus: "series",
          },
          data: [120, 132, 101, 134, 90, 230, 210],
        },
        {
          name: "Union Ads",
          type: "bar",
          stack: "Ad",
          emphasis: {
            focus: "series",
          },
          data: [220, 182, 191, 234, 290, 330, 310],
        },
        {
          name: "Video Ads",
          type: "bar",
          stack: "Ad",
          emphasis: {
            focus: "series",
          },
          data: [150, 232, 201, 154, 190, 330, 410],
        },
        {
          name: "Search Engine",
          type: "bar",
          data: [862, 1018, 964, 1026, 1679, 1600, 1570],
          emphasis: {
            focus: "series",
          },
          markLine: {
            lineStyle: {
              type: "dashed",
            },
            data: [
              [
                {
                  type: "min",
                },
                {
                  type: "max",
                },
              ],
            ],
          },
        },
        {
          name: "Baidu",
          type: "bar",
          barWidth: 5,
          stack: "Search Engine",
          emphasis: {
            focus: "series",
          },
          data: [620, 732, 701, 734, 1090, 1130, 1120],
        },
        {
          name: "Google",
          type: "bar",
          stack: "Search Engine",
          emphasis: {
            focus: "series",
          },
          data: [120, 132, 101, 134, 290, 230, 220],
        },
        {
          name: "Bing",
          type: "bar",
          stack: "Search Engine",
          emphasis: {
            focus: "series",
          },
          data: [60, 72, 71, 74, 190, 130, 110],
        },
      ],
    },
  },
});

// 表格数据
Mock.mock("/test_api/v1/table", "get", {
  code: 200,
  msg: "操作成功",
  data: {
    list: [
      {
        id: 1,
        name: "唱",
        status: true,
        created_at: "2024-01-01T08:00:00.000+08:00",
      },
      {
        id: 2,
        name: "跳",
        status: true,
        created_at: "2024-02-01T08:00:00.000+08:00",
      },
      {
        id: 3,
        name: "Rap",
        status: true,
        created_at: "2024-03-01T08:00:00.000+08:00",
      },
      {
        id: 4,
        name: "篮球",
        status: true,
        created_at: "2024-04-01T08:00:00.000+08:00",
      },
      {
        id: 5,
        name: "Music",
        status: true,
        created_at: "2024-05-01T08:00:00.000+08:00",
      },
      {
        id: 6,
        name: "足球",
        status: false,
        created_at: "2024-06-01T08:00:00.000+08:00",
      },
      {
        id: 7,
        name: "棒球",
        status: false,
        created_at: "2024-07-01T08:00:00.000+08:00",
      },
      {
        id: 8,
        name: "乒乓球",
        status: false,
        created_at: "2024-08-01T08:00:00.000+08:00",
      },
    ],
    page: 1,
    pageSize: 20,
    total: 8,
  },
});
